﻿// We are given 5 integer numbers. Write a program that checks if the sum of some subset of them is 0. 
// Example: 3, -2, 1, 1, 8 -> 1+1-2=0.

using System;

class CheckSum0ofSubset
{
    static void Main()
    {
        Console.Write("Enter first number : ");
        string numbStr1 = Console.ReadLine();
        double numb1;
        while (!double.TryParse(numbStr1, out numb1))
        {
            Console.Write("Invalid input. Please, enter new number : ");
            numbStr1 = Console.ReadLine();
        }

        Console.Write("Enter second number : ");
        string numbStr2 = Console.ReadLine();
        double numb2;
        while (!double.TryParse(numbStr2, out numb2))
        {
            Console.Write("Invalid input. Please, enter new number : ");
            numbStr2 = Console.ReadLine();
        }

        Console.Write("Enter third number : ");
        string numbStr3 = Console.ReadLine();
        double numb3;
        while (!double.TryParse(numbStr3, out numb3))
        {
            Console.Write("Invalid input. Please, enter new number : ");
            numbStr3 = Console.ReadLine();
        }

        Console.Write("Enter fourth number : ");
        string numbStr4 = Console.ReadLine();
        double numb4;
        while (!double.TryParse(numbStr4, out numb4))
        {
            Console.Write("Invalid input. Please, enter new number : ");
            numbStr4 = Console.ReadLine();
        }

        Console.Write("Enter fifth number : ");
        string numbStr5 = Console.ReadLine();
        double numb5;
        while (!double.TryParse(numbStr5, out numb5))
        {
            Console.Write("Invalid input. Please, enter new number : ");
            numbStr5 = Console.ReadLine();
        }

        bool sum0 = false;

        if (numb1 + numb2 + numb3 + numb4 + numb5 == 0)
        {
            sum0 = true;
        }
        else if (numb1 + numb2 + numb3 + numb4 == 0)
        {
            sum0 = true;
        }
        else if (numb1 + numb2 + numb3 + numb5 == 0)
        {
            sum0 = true;
        }
        else if (numb1 + numb2 + numb4 + numb5 == 0)
        {
            sum0 = true;
        }
        else if (numb1 + numb3 + numb4 + numb5 == 0)
        {
            sum0 = true;
        }
        else if (numb1 + numb2 + numb3 == 0)
        {
            sum0 = true;
        }
        else if (numb1 + numb2 + numb4 == 0)
        {
             sum0 = true;
        }
        else if (numb1 + numb2 + numb5 == 0)
        {
             sum0 = true;
        }
        else if (numb1 + numb3 + numb4 == 0)
        {
            sum0 = true;
        }
        else if (numb1 + numb3 + numb5 == 0)
        {
            sum0 = true;
        }
        else if (numb1 + numb4 + numb5 == 0)
        {
             sum0 = true;
        }
        else if (numb1 + numb2 == 0)
        {
             sum0 = true;
        }
        else if (numb1 + numb3 == 0)
        {
            sum0 = true;
        }
        else if (numb1 + numb4 == 0)
        {
              sum0 = true;
        }
        else if (numb1 + numb5 == 0)
        {
            sum0 = true;
        }
        else if (numb2 + numb3 + numb4 + numb5 == 0)
        {
            sum0 = true;
        }
        else if (numb2 + numb3 + numb4 == 0)
        {
            sum0 = true;
        }
        else if (numb2 + numb3 + numb5 == 0)
        {
            sum0 = true;
        }
        else if (numb2 + numb4 + numb5 == 0)
        {
            sum0 = true;
        }
        else if (numb2 + numb3 == 0)
        {
            sum0 = true;
        }
        else if (numb2 + numb4 == 0)
        {
            sum0 = true;
        }
        else if (numb2 + numb5 == 0)
        {
            sum0 = true;
        }
        else if (numb3 + numb4 + numb5 == 0)
        {
            sum0 = true;
        }
        else if (numb3 + numb4 == 0)
        {
            sum0 = true;
        }
        else if (numb3 + numb5 == 0)
        {
            sum0 = true;
        }
        else if (numb4 + numb5 == 0)
        {
            sum0 = true;
        }

        if (sum0 == true)
        {
            Console.WriteLine("Yes, there is a subset which sum is 0.");
        }
        else
        {
            Console.WriteLine("No, there is NOT a subset which sum is 0.");
        }
    }
}
